<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    </style>
</head>
<body>
<div></div>
<input type="search" placeholder="搜索歌词、歌手">
               
    <input  type="search" id="search">
    <button id="btn">搜索</button>
    <button  id="cl">shan除全部</button>
    <ul id="ul">

    </ul>
</body>
<script>
    function hanshu(){
        let shuzu=JSON.parse(localStorage.getItem('singer'));
        string='';
        shuzu.forEach(value => {

            // $("#ul")
            string+=
            `
            <li>${value} <button  onclick='del("${value}")'>删除</button>  </li>
            `
            // console.log(value)
        });
        $("#ul").innerHTML=string
    }
</script>
<script>

    console.log("daozhelil")
    function del(sc){
        aa.forEach(function(value,index,arr) {
            //console.log(value)
            if(value==sc){
                aa.splice(index,1)
                console.log(aa)
            }
        })
        
    }

</script>
<script src="../js/gete.js" ></script>
<script>
    let aa=["zz","dd","dfg"]
    localStorage.setItem('singer',JSON.stringify(aa))//整存
    console.log(localStorage.getItem('singer'))
    console.log(JSON.parse(localStorage.getItem('singer')))//整取
    hanshu();
    $("#btn").onclick=function(){
        aa.push($("#search").value)
        localStorage.setItem('singer',JSON.stringify(aa))
        hanshu();
    }
    $("#cl").onclick=function(){
        localStorage.clear()
        $("#ul").innerHTML="";
        aa=[];
    }
    //localStorage.removeItem("name")  // 删除单个
    //localStorage.clear()//清除全部
    //查找
    // let a =localStorage.getItem("name")
    // alert(a)
</script>
</html>